<?php
/**
 * 导航类，头部导航管理类  
 * @author jianhui
 *
 */
class Navbar{
    var $user = null;
    var $menuList = array();
    /**
     * 构造函数
     * @param array $user
     */
    function Navbar($user){
        $this->user = $user;
    }
    /**
     * 获取菜单列表
     */
    function getNavbarList(){
        if ($this->user['userRole'] == 1){
            //总控表
            $this->menuList[] = array('focusTag'=>'Main','url'=>printUrl('Main', 'storeTotal'), 'title'=>'费用使用总控表');
            //单店基金
            $this->menuList[] = array('focusTag'=>'SingleBudget','url'=>printUrl('SingleBudget', 'storeList'), 'title'=>'单店基金申报', 'child' => array(
                    array('url'=>printUrl('SingleBudget', 'storeList'), 'title'=>'单店基金预算申请','childFocus'=>array(
                        'SingleBudget_storeList','SingleBudget_storeEdit','SingleBudget_check','SingleProject_add','SingleProject_edit','SingleProject_childDetail'
                    )),
                    array('url'=>printUrl('SingleSettle', 'storeList'), 'title'=>'单店基金结算申请','childFocus'=>array(
                        'SingleSettle_storeList','SingleSettle_StoreUpload','SingleSettle_check','SingleSettle_storeEdit',
                    )),
                ));
            //城市基金
            $this->menuList[] = array('focusTag'=>'CityBudget','url'=>printUrl('CityBudget', 'storeList'), 'title'=>'城市提升基金申报', 'child' => array(
                    array('url'=>printUrl('CityBudget', 'storeList'), 'title'=>'城市提升基金预算申请','childFocus'=>array(
                        'CityBudget_storeList','CityBudget_storeEdit','CityBudget_check',
                        'CityProject_add','CityProject_edit','CityProject_childDetail','CityProject_add',
                    )),
                    array('url'=>printUrl('CitySettle', 'storeList'), 'title'=>'城市提升基金结算申请','childFocus'=>array(
                        'CitySettle_storeList','CitySettle_storeEdit','CitySettle_check',
                    )),
                ));
            //BTL基金
            $this->menuList[] = array('focusTag'=>'CarBudget','url'=>printUrl('CarBudget','storeList'),'title'=>'BTL基金申报','child' => array(
                    array('url'=>printUrl('CarBudget','storeList'),'title'=>'车展基金预算申报','childFocus'=>array(
                        'CarBudget_storeList','CarBudget_storeEdit','CarBudget_check','CarProject_add',
                        'CarProject_childDetail',
                    )),
                    array('url'=>printUrl('CarSettle','storeList'),'title'=>'车展基金结算申报','childFocus'=>array(
                        'CarSettle_storeList','CarSettle_StoreUpload','CarSettle_check','CarSettle_storeEdit'
                    )),
                    'line',
                    array('url'=>printUrl('XunBudget','storeList'),'title'=>'巡展基金预算查看','childFocus'=>array(
                        'XunBudget_storeList','XunBudget_check'
                    )),
                    array('url'=>printUrl('XunSettle','storeList'),'title'=>'巡展基金结算查看','childFocus'=>array(
                        'XunSettle_storeList','XunSettle_check',
                    )),
                ));
            //固定传播基金
            $this->menuList[] = array('focusTag'=>'SpreadBudget','url'=>printUrl('SpreadBudget','storeList'),'title'=>'固定传播基金申报','child'=>array(
                    array('url'=>printUrl('SpreadBudget','storeList'),'title'=>'固定传播基金新增申请','childFocus'=>array(
                        'SpreadBudget_storeList','SpreadBudget_storeAdd','SpreadBudget_check'
                    )),
                    array('url'=>printUrl('SpreadSettle','storeList'),'title'=>'固定传播发布与检核','childFocus'=>array(
                        'SpreadSettle_storeList','SpreadSettle_storeEdit','SpreadSettle_check'
                    )),
                ));
            //专项单店基金
            $this->menuList[] = array('focusTag'=>'SpecialBudget','url'=>printUrl('SpecialBudget','storeList'),'title'=>'专项基金申报','child'=>array(
                    array('url'=>printUrl('SpecialBudget','storeList'),'title'=>'专项单店基金预算申请','childFocus'=>array(
                        'SpecialBudget_storeList','SpecialBudget_storeEdit','SpecialBudget_check','SpecialProject_add','SpecialProject_edit','SpecialProject_childDetail'
                    )),
                    array('url'=>printUrl('SpecialSettle','storeList'),'title'=>'专项单店基金结算申请','childFocus'=>array(
                        'SpecialSettle_storeList','SpecialSettle_StoreUpload','SpecialSettle_check','SpecialSettle_storeEdit',
                    )),
                    'line',
                    array('url'=>printUrl('SpecityBudget','storeList'),'title'=>'专项城市基金预算申请','childFocus'=>array(
                        'SpecityBudget_storeList','SpecityBudget_storeEdit','SpecityBudget_check','SpecityProject_add','SpecityProject_edit','SpecityProject_childDetail'
                    )),
                    array('url'=>printUrl('SpecitySettle','storeList'),'title'=>'专项城市基金结算申请','childFocus'=>array(
                        'SpecitySettle_storeList','SpecitySettle_StoreUpload','SpecitySettle_check','SpecitySettle_storeEdit',
                    )),
                ));
            //补报
            $this->menuList[] = array('focusTag'=>'Supplement','url'=>printUrl('SingleBudgetAgain', 'storeList'), 'title'=>'RMP补报', 'child'=>array(
                    array('url'=>printUrl('SingleBudgetAgain', 'storeList'), 'title'=>'单店基金补报预算申请','childFocus'=>array(
                        'SingleBudgetAgain_storeList','SingleBudgetAgain_storeEdit','SingleProject_add','SingleBudgetAgain_check','SingleProject_add','SingleProject_edit','SingleProject_childDetail'
                    )),
                    array('url'=>printUrl('SingleSettleAgain', 'storeList'), 'title'=>'单店基金补报结算申请','childFocus'=>array(
                        'SingleSettleAgain_storeList','SingleSettleAgain_storeEdit','SingleSettleAgain_check'
                    )),
                    'line',
                    array('url'=>printUrl('CityBudgetAgain', 'storeList'), 'title'=>'城市基金补报预算申请','childFocus'=>array(
                        'CityBudgetAgain_storeList','CityBudgetAgain_storeEdit','CityProject_add','CityBudgetAgain_check',
                        'CityProject_add','CityProject_edit','CityProject_childDetail','CityProject_add',
                    )),
                    array('url'=>printUrl('CitySettleAgain', 'storeList'), 'title'=>'城市基金补报结算申请','childFocus'=>array(
                        'CitySettleAgain_storeList','CitySettleAgain_storeEdit','CitySettleAgain_check'
                    )),
                    /*'line',
                    array('url'=>printUrl('SpecialBudgetAgain', 'storeList'), 'title'=>'专项单店基金补报预算申请','childFocus'=>array(
                        'SpecialBudgetAgain_storeList','SpecialBudgetAgain_storeEdit','SpecialProject_add','SpecialBudgetAgain_check','SpecialProject_add','SpecialProject_edit','SpecialProject_childDetail'
                    )),
                    array('url'=>printUrl('SpecialSettleAgain', 'storeList'), 'title'=>'专项单店基金补报结算申请','childFocus'=>array(
                        'SpecialSettleAgain_storeList','SpecialSettleAgain_storeEdit','SpecialSettleAgain_check'
                    )),*/
                ));
            //RMP助手
            $this->menuList[] = array('focusTag'=>'Help','url'=>printUrl('Help', 'fileCheck'), 'title'=>'RMP助手');
        }else{
            //总控表
            $this->menuList[] = array('focusTag'=>'Main','url'=>printUrl('Main', 'adminTotal'),'title'=>'费用使用总控表');
            //单店基金
            $this->menuList[] = array('focusTag'=>'SingleBudget','url'=>printUrl('SingleBudget', 'adminList'), 'title'=>'单店基金管理', 'child'=>array(
                    array('url'=>printUrl('SingleBudget', 'adminList'), 'title'=> '单店基金预算管理','childFocus'=>array(
                        'SingleBudget_adminList','SingleBudget_check','SingleBudget_adminAudit',
                    )),
                    array('url'=>printUrl('SingleSettle', 'adminList'), 'title'=> '单店基金结算管理','childFocus'=>array(
                        'SingleSettle_adminList','SingleSettle_check','SingleSettle_adminAudit','SingleSettle_adminChange',
                    )),
                ));
            //城市基金
            $this->menuList[] = array('focusTag'=>'CityBudget','url'=>printUrl('CityBudget', 'adminList'), 'title'=>'城市提升基金管理', 'child'=>array(
                    array('url'=>printUrl('CityBudget', 'adminList'), 'title'=>'城市提升基金预算管理','childFocus'=>array(
                        'CityBudget_adminList','CityBudget_adminList','CityBudget_check','CityBudget_adminAudit',
                    )),
                    array('url'=>printUrl('CitySettle', 'adminList'), 'title'=>'城市提升基金结算管理','childFocus'=>array(
                        'CitySettle_adminList','CitySettle_check','CitySettle_adminAudit','CitySettle_adminChange',
                    )),
                ));
            //BTL基金
            $this->menuList[] = array('focusTag'=>'CarBudget','url'=>printUrl('CarBudget','adminList'),'title'=>'BTL基金管理','child' => array(
                    array('url'=>printUrl('CarBudget','adminList'),'title'=>'车展基金预算管理','childFocus'=>array(
                        'CarBudget_adminList','CarBudget_adminAudit','CarBudget_check',
                    )),
                    array('url'=>printUrl('CarSettle','adminList'),'title'=>'车展基金结算管理','childFocus'=>array(
                        'CarSettle_adminList','CarSettle_check','CarSettle_adminAudit','CarSettle_adminChange'
                    )),
                    'line',
                    array('url'=>printUrl('XunBudget','adminList'),'title'=>'巡展基金预算管理','childFocus'=>array(
                        'XunBudget_adminList','XunBudget_check'
                    )),
                    array('url'=>printUrl('XunSettle','adminList'),'title'=>'巡展基金结算管理','childFocus'=>array(
                        'XunSettle_adminList','XunSettle_check','XunSettle_adminAudit'
                    )),
                 ));
            //固定传播基金
            $childMenu = array();
            $childMenu[] = array('url'=>printUrl('SpreadBudget','adminList'),'title'=>'新增申请管理','childFocus'=>array(
                        'SpreadBudget_adminList','SpreadBudget_adminAudit','SpreadBudget_check'
                    ));
            $childMenu[] = array('url'=>printUrl('SpreadSettle','adminList'),'title'=>'固定传播发布与检核','childFocus'=>array(
                        'SpreadSettle_adminList','SpreadSettle_adminAudit','SpreadSettle_check'
                    ));
            if ($this->user['userRole'] == 6){
                $childMenu[] = array('url'=>printUrl('SpreadSettle','applyTimeList'),'title'=>'申报审核时间管理','childFocus'=>array(
                    'SpreadSettle_applyTimeList','SpreadSettle_roleList','SpreadSettle_roleAdd'
                ));
                $childMenu[] = array('url'=>printUrl('SpreadSettle','timeUnitList'),'title'=>'双月检核时间管理','childFocus'=>array(
                    'SpreadSettle_timeUnitList',
                ));
            }
            $this->menuList[] = array('focusTag'=>'SpreadBudget','url'=>printUrl('SpreadBudget','adminList'),'title'=>'固定传播基金管理','child'=>$childMenu);
            //专项单店基金（督导、大区总监可审核，其他角色可查看）
            $this->menuList[] = array('focusTag'=>'SpecialBudget','url'=>printUrl('SpecialBudget', 'adminList'), 'title'=>'专项基金管理', 'child'=>array(
                array('url'=>printUrl('SpecialBudget', 'adminList'), 'title'=> '专项单店基金预算管理','childFocus'=>array(
                    'SpecialBudget_adminList','SpecialBudget_check','SpecialBudget_adminAudit',
                )),
                array('url'=>printUrl('SpecialSettle', 'adminList'), 'title'=> '专项单店基金结算管理','childFocus'=>array(
                    'SpecialSettle_adminList','SpecialSettle_check','SpecialSettle_adminAudit','SpecialSettle_adminChange',
                )),
                'line',
                array('url'=>printUrl('SpecityBudget', 'adminList'), 'title'=> '专项城市基金预算管理','childFocus'=>array(
                    'SpecityBudget_adminList','SpecityBudget_check','SpecityBudget_adminAudit',
                )),
                array('url'=>printUrl('SpecitySettle', 'adminList'), 'title'=> '专项城市基金结算管理','childFocus'=>array(
                    'SpecitySettle_adminList','SpecitySettle_check','SpecitySettle_adminAudit','SpecitySettle_adminChange',
                )),
            ));
            //补报
            $childMenu = array();
            $title = in_array($this->user['userRole'], array(5,6)) ? "管理" : '审核';
            //单店基金（督导、大区总监可审核，其他角色可查看）
            $childMenu[] = array('url'=>printUrl('SingleBudgetAgain', 'adminList'), 'title'=>'单店基金预算'.$title,'childFocus'=>array(
                'SingleBudgetAgain_adminList','SingleBudgetAgain_adminAudit','SingleBudgetAgain_check'
            ));
            $childMenu[] = array('url'=>printUrl('SingleSettleAgain', 'adminList'), 'title'=>'单店基金结算'.$title,'childFocus'=>array(
                'SingleSettleAgain_adminList','SingleSettleAgain_adminAudit','SingleSettleAgain_check'
            ));
            $childMenu[] = 'line';
            //城市基金（专员、大区总监可审核，其他角色可查看）
            $childMenu[] = array('url'=>printUrl('CityBudgetAgain', 'adminList'), 'title'=>'城市基金预算'.$title,'childFocus'=>array(
                'CityBudgetAgain_adminList','CityBudgetAgain_adminAudit','CityBudgetAgain_check'
            ));
            $childMenu[] = array('url'=>printUrl('CitySettleAgain', 'adminList'), 'title'=>'城市基金结算'.$title,'childFocus'=>array(
                'CitySettleAgain_adminList','CitySettleAgain_adminAudit','CitySettleAgain_check'
            ));
            $childMenu[] = 'line';
            //专项单店基金（督导、大区总监可审核，其他角色可查看）
            /* $childMenu[] = array('url'=>printUrl('SpecialBudgetAgain', 'adminList'), 'title'=>'专项单店基金预算'.$title,'childFocus'=>array(
                'SpecialBudgetAgain_adminList','SpecialBudgetAgain_adminAudit','SpecialBudgetAgain_check'
            ));
            $childMenu[] = array('url'=>printUrl('SpecialSettleAgain', 'adminList'), 'title'=>'专项单店基金结算'.$title,'childFocus'=>array(
                'SpecialSettleAgain_adminList','SpecialSettleAgain_adminAudit','SpecialSettleAgain_check'
            ));
            $childMenu[] = 'line'; */
            //地区和总部可开通普通补报和特殊补报，地区的开始和结束时间范围有限制
            if (in_array($this->user['userRole'], array(5,6))){
                $childMenu[] = 'line';
                $childMenu[] = array('url'=>printUrl('Supplement', 'roleList', array('type'=>1)), 'title'=>'补报管理','childFocus'=>array(
                    'Supplement_roleList1','Supplement_roleAdd1','Supplement_roleEdit1'
                ));
                $childMenu[] = array('url'=>printUrl('Supplement', 'roleList', array('type'=>2)), 'title'=>'特殊补报管理','childFocus'=>array(
                    'Supplement_roleList2','Supplement_roleAdd2','Supplement_roleEdit2'
                ));
            }
            //合并
            $this->menuList[] = array(
                'focusTag'=>'Supplement','url'=>printUrl('SingleBudgetAgain','adminList'),'title' => 'RMP补报管理','child' => $childMenu,
            );
            //报表管理菜单
            $this->menuList[] = array('focusTag'=>'Report_index','url'=>printUrl('Report', 'index'), 'title'=>'报表管理');
            if ($this->user['userRole'] == 6){
                $this->menuList[] = array('focusTag'=>'Import','url'=>printUrl('Import', 'index'), 'title'=>'数据导入');
                $this->menuList[] = array('focusTag'=>'Help','url'=>printUrl('Help', 'fileList'), 'title'=>'RMP助手');
            }else{
                $this->menuList[] = array('focusTag'=>'Help','url'=>printUrl('Help', 'fileCheck'), 'title'=>'RMP助手');
            }
        }
        return $this->menuList;
    }
    /**
     * 判断是否提前显示
     * @return boolean
     */
    function isPreShow(){
        if ($this->user['isPreShow']) {
            return true;
        }else{
            return false;
        }
        //自定义类使用CI资源使用此方法
        $CI =& get_instance();
        $ip = $CI->input->ip_address();
        $allowIpList = array('192.168.1.101','183.57.148.133','183.57.148.135');
        if (in_array($ip, $allowIpList)){
            return true;
        }else{
            return false;
        }
    }
}